package com.qf.mrboot2.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author: xiyang
 * @FileName: Swagger2Config
 * @Date: Created in 2021/5/28 08:38
 * @Vserion:
 * @Description: TODO
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.qf.mrboot2.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    /**
     * apiInfo指的是接口文档信息
     */

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("接口文档的名称")
                .description("接口文档的描述")
                .contact(new Contact("作者名称","作者详情的链接","邮箱"))
                .termsOfServiceUrl("项目的启动地址")
                .version("1.0")
                .build();
    }





}
